package cn.xiaopengstack.infrastructure.persistent.dao;

import cn.xiaopengstack.infrastructure.persistent.po.GroupBuyOrder;
import cn.xiaopengstack.infrastructure.persistent.po.GroupBuyOrderList;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
* @author jiangyangang
* @description 针对表【group_buy_order_list(拼团订单详情表)】的数据库操作Mapper
* @createDate 2025-10-16 17:42:38
* @Entity cn.xiaopengstack.infrastructure.persistent.po.GroupBuyOrderList
*/
@Mapper
public interface IGroupBuyOrderListDao {

    int insertSelective(GroupBuyOrderList record);

    GroupBuyOrderList selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(GroupBuyOrderList record);

    /**
     * 查询未支付的拼团营销订单
     * @param userId
     * @param outOrderId
     * @return
     */
    GroupBuyOrderList queryUnPayMarketPayOrder(@Param("userId") String userId, @Param("outOrderId") String outOrderId);

    /**
     * 更新结算状态
     * @param orderId
     * @return
     */
    int updateSettlementStatus(@Param("orderId") String orderId, @Param("userId") String userId, @Param("outTradeTime") Date outTradeTime);

    /**
     * 查询外部单号列表
     * @param teamId
     * @return
     */
    List<String> queryOrderListOutTradeNoList(@Param("teamId") String teamId);

    List<GroupBuyOrderList> queryInProgressOrderListsByTeamIds(@Param("teamIds") List<String> teamIds);

    /**
     * 查询拼团明细
     * @param orderId
     * @return
     */
    GroupBuyOrderList queryOrderListByOrderId(@Param("orderId") String orderId);

    /**
     * 更新状态为退款
     * @param orderId
     * @return
     */
    int updateRefundStatus(@Param("orderId") String orderId);

    /**
     * 查询拼团列表
     * @param userId
     * @return
     */
    List<GroupBuyOrderList> queryListByUserId(@Param("userId") String userId);
}
